Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #729

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #729

wants to merge 3 commits into from

Conversation

frezworx
Copy link

No description provided.

app/main.py Outdated
class Carnivore(Animal):

def bite(self, animal: Animal) -> None:
if isinstance(animal, Carnivore):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite your code without return
Screenshot 2023-10-11 at 17 07 07

app/main.py Outdated
self.alive.append(self)

def __repr__(self) -> str:
return (f""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-10-11 at 17 09 29

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several changes were requested.

app/main.py Outdated
self.name = name
self.health = health
self.hidden = hidden
self.alive.append(self)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alive is not an instance attribute, it is a class attribute. Call it from Animal here.

app/main.py Outdated
class Carnivore(Animal):

def bite(self, animal: Animal) -> None:
if not isinstance(animal, Carnivore):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make check that the instance is exactly Herbivore, your code may be corrupted in case there would be other animals added later.

@frezworx frezworx requested a review from Dimosphen1 October 12, 2023 10:00
Copy link

@Polyakiv-Andrey Polyakiv-Andrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants